//
//  Size.swift
//  ADKit
//
//  Created by Adoma on 2020/10/22.
//

import Foundation

/// by ADKit
public let kScreenWidth = UIScreen.main.bounds.width

/// by ADKit
public let kScreenHeight = UIScreen.main.bounds.height

/// by ADKit
public let kSafeAreaTop = WindowManager.keyWindow?.safeAreaInsets.top ?? 0

/// by ADKit
public let kSafeAreaBottom = WindowManager.keyWindow?.safeAreaInsets.bottom ?? 0

/// by ADKit
public let kSeparatorLineH = 1/UIScreen.main.scale

public enum ADZoomStyle {
    case `default`, ceil, floor, round
}

public func AD_ZOOM_STYLE(value: CGFloat, style: ADZoomStyle = .default) -> CGFloat {
    switch style {
    case .default:
        return value
    case .ceil:
        return ceil(value)
    case .floor:
        return floor(value)
    case .round:
        return round(value)
    }
}

/// by ADKit
public func AD_ZOOM_WIDTH(_ value: CGFloat, base: CGFloat = 375, style: ADZoomStyle = .default) -> CGFloat {
    return AD_ZOOM_STYLE(value: value*kScreenWidth/base, style: style)
}

/// by ADKit
public func AD_ZOOM_HEIGHT(_ value: CGFloat, base: CGFloat = 812, style: ADZoomStyle = .default) -> CGFloat {
    return AD_ZOOM_STYLE(value: value*kScreenHeight/base, style: style)
}

